package com.atguigu.guli.service.base.exception;

import com.atguigu.guli.service.base.result.ResultCodeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author dyqstart
 * @create 2021-07-06-19:33
 * @since 1.0.0
 */
@Data
@NoArgsConstructor
public class GuliException extends RuntimeException {

    //状态码
    private Integer code;

    /**
     * 接受响应状态码
     *
     * @param code
     * @param message
     */
    public GuliException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public GuliException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ",message=" + this.getMessage() +
                '}';
    }
}
